home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / mus / edit / amisox_wav.lha / ami.c < prev    next >
C/C++ Source or Header  |  1992-05-08  |  1KB  |  48 lines

  1. /* needed functions for Amiga sox *
  2.  * D. Champion, 26 Apr 1992       *
  3.  * other necessities, such as     *
  4.  * bcopy() and index() #defines,  *
  5.  * may be found in "st.h"         */
  6.  
  7. #include <exec/types.h>
  8. #include <exec/tasks.h>
  9. #include <stdio.h>
  10.  
  11. #ifndef P_tmpdir
  12. #define P_tmpdir    "t:"
  13. #define B_tmpnam    5
  14. #undef L_tmpnam
  15. #define L_tmpnam    sizeof(P_tmpdir)+B_tmpnam+21
  16.     /* sizeof(P_tmpdir) includes terminating null; B_tmpnam is how much   *
  17.      * of myname to include; 8x2 for hex longs + 3 dots + 2 sequence nums */
  18. #endif
  19.  
  20. char tmpnam_count=0;
  21.  
  22. char *tmpnam(char *s)
  23. {
  24. extern char *myname;    /* myname MUST exist! */
  25. extern char tmpnam_count;
  26. char *uniqsuff=".00000000.00000000.00";
  27. int i;
  28.  
  29. strcpy (s,P_tmpdir);
  30. strncat(s,myname,B_tmpnam);    /* start tmpfilename with 1st B_tmpnam chars of myname */
  31. sprintf(uniqsuff,".%8x.%8x.%2x\0",(ULONG)FindTask(NULL),(ULONG)time(),(char)tmpnam_count);
  32. for(i=0;i<L_tmpnam+B_tmpnam;i++) {
  33.     if (uniqsuff[i]==' ') uniqsuff[i]='0';
  34. }
  35. strcat (s,uniqsuff);
  36. tmpnam_count++;
  37.  
  38. return(s);
  39. }
  40.  
  41. FILE *tmpfile(void)
  42. {
  43. FILE *file;
  44. char fnam[L_tmpnam];
  45.  
  46. return(file=fopen(tmpnam(fnam),"wb+"));
  47. }
  48.